home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / dialogic.zip / EXAMPLE3.BAS < prev    next >
BASIC Source File  |  1990-01-31  |  6KB  |  146 lines

  1. '
  2. '┌───────────────────────────────────────────────────────┐
  3. '│ Written by Jonathan S. Waldman                        │
  4. '│ (C) 1989, 1990 Jonathan S. Waldman & Dialog Software  │
  5. '│ (C) Crescent Software.                                │
  6. '│ All rights reserved.                                  │
  7. '└───────────────────────────────────────────────────────┘
  8.  
  9. '============
  10. 'DiaLogic
  11. 'EXAMPLE3.BAS
  12. '============
  13.  
  14. '$INCLUDE: 'DIALOGIC.BI'         'include our DiaLogic TYPE definitions
  15.  
  16. '====================
  17. 'Initialize the mouse
  18. '====================
  19.  
  20.    CALL InitMouse(There%)        'see if mouse and driver are there
  21.    IF There% THEN                'if yes then
  22.       CALL ShowCursor            'show the mouse
  23.       CALL TextCursor(0, 4)      'use this to insure mouse is always visible
  24.    END IF
  25.  
  26. '======
  27. 'Set-up
  28. '======
  29.  
  30.    CALL HideCursor               'hide the mouse cursor during CLS & PRINTs
  31.    WIDTH , 25                    'insure we're in 25-line mode
  32.    COLOR 15, 1
  33.    CLS                           'clear the screen
  34.  
  35.  
  36. '========================
  37. 'REDIM the arrays for now
  38. '========================
  39.  
  40.    '$DYNAMIC                     'make all arrays dynamic
  41.    MaxDBE = 20                   'use for our dimension statements
  42.                                  '  20 dialog box elements will be our max
  43.    REDIM SHARED DB(2, MaxDBE) AS DialogType  'REDIM these TYPE arrays
  44.    REDIM SHARED LB(0) AS DialogText          '  dynamically
  45.  
  46. '=======================================
  47. 'Define some convenient string variables
  48. '=======================================
  49.  
  50.    PRINT
  51.    PRINT "   This is an example of stacked dialog boxes.  Choose <Help> to see this."
  52.    PRINT "   The <Help> message is displayed on top of the Find dialog box.  When"
  53.    PRINT "   the help is acknowledged, it is removed from the display and the Find"
  54.    PRINT "   dialog box is restored with all previous selections intact.  DiaLogic"
  55.    PRINT "   automatically preserves underlying information when Level% is > 1."
  56.    PRINT "   Notice that, unlike Example1, the Find dialog box is NOT regenerated"
  57.    PRINT "   but rather is re-activated.  In other words, in stacked dialog boxes the"
  58.    PRINT "   underlying dialog box is never removed from the screen."
  59.    PRINT
  60.  
  61.    CALL ShowCursor               'show it again
  62.  
  63.    Cancel$ = CHR$(27)            'these are our string assignments, also used
  64.    Help$ = CHR$(0) + CHR$(59)    '  in the FIND.DB template.
  65.    OK$ = CHR$(13)
  66.  
  67.    REDIM SHARED DB(2, MaxDBE) AS DialogType  'REDIM these TYPE arrays
  68.                                  'this example requires 2 Levels in DB()
  69.    REDIM SHARED LB(10) AS DialogText
  70.  
  71.    Level% = 1                    'set Level% to 1 for the Find dialog box
  72.    '$INCLUDE: 'FIND.DB'          'include the Find dialog box template
  73.    Action% = 6                   'set Action% to 6
  74.    DO
  75.       Focus% = 0                 'set the input focus to auto -- 0
  76.       CALL DiaLogic(DB(), LB(), Action%, Focus%, Ky$)
  77.      
  78.       '=================================
  79.       'Store the Find dialog box results
  80.       '=================================
  81.      
  82.       Level% = 1                          'insure that the Level is
  83.                                           '   correct
  84.  
  85.       Search$ = MID$(DB(Level%, 2).TextString, 1, DB(Level%, 2).NumberOne)
  86.                                           'Search$ holds our search string
  87.       MatchCase = DB(Level%, 3).Default   '-1 if Match Case is checked
  88.       WholeWord = DB(Level%, 4).Default   '-1 if Whole Words is checked
  89.       SearchType = DB(Level%, 5).Default  ' 1 for Active Window, 2 for
  90.                                           ' Current Module, or 3 for
  91.                                           ' All Modules
  92.  
  93.       SELECT CASE Ky$
  94.          CASE Help$              '<Help> was selected
  95.             Level% = 2           'make Level% = 2 for stacking a Help message
  96.             '$INCLUDE: 'FINDH.DB''include Help dialog box template
  97.             Action% = 0          'set Action% to 0 so Help is automatically
  98.                                  '  removed from the screen
  99.             Focus% = 0           'set the input focus to auto -- 0
  100.             CALL DiaLogic(DB(), LB(), Action%, Focus%, Ky$)
  101.             Action% = 2           'refresh the Find dialog box
  102.             CALL DiaLogic(DB(), LB(), Action%, Focus%, Ky$)
  103.             Action% = 7          'prepare Find to be re-activated
  104.          CASE OK$
  105.  
  106.             '=====================================
  107.             'Remove the dialog box from the screen
  108.             '=====================================
  109.  
  110.             Action% = 5
  111.             CALL DiaLogic(DB(), LB(), Action%, Focus%, Ky$)
  112.  
  113.             '==============================
  114.             'Print the results to the user.
  115.             '==============================
  116.  
  117.             PRINT "   Your search string is " + LEFT$(Search$, 40) + " ..."
  118.             IF MatchCase THEN
  119.                PRINT "   Match Upper/Lower Case was checked."
  120.             END IF
  121.             IF WholeWord THEN
  122.                PRINT "   Whole Words Only was checked."
  123.             END IF
  124.             PRINT "   " + RTRIM$(MID$(DB(Level%, 5 + SearchType).Text, 5)) + " was selected."
  125.             ExitLoop = -1        'bail out
  126.          CASE Cancel$
  127.  
  128.             '=====================================
  129.             'Remove the dialog box from the screen
  130.             '=====================================
  131.  
  132.             Action% = 5
  133.             CALL DiaLogic(DB(), LB(), Action%, Focus%, Ky$)
  134.  
  135.             ExitLoop = -1        'bail out
  136.          CASE ELSE
  137.             Action% = 5
  138.             CALL DiaLogic(DB(), LB(), Action%, Focus%, Ky$)
  139.             ExitLoop = -1        'bail out
  140.       END SELECT
  141.    LOOP UNTIL ExitLoop
  142.    COLOR 7, 0
  143.    CALL HideCursor
  144.    END
  145.  
  146.